package zzws.logon;

import ws.db.sql.*;
import ws.db.readtable.*;
import zzws.dbstructure.*;
import ws.log.*;

public class User {
	
	/*
	 *  <option value="1">校级管理员</option>
     *  <option value="2">学生</option>
     *  <option value="3">学院/用人单位</option>
	 * */
	private String Identity;
	private String UserName;
	private String UserPass;
	
	/**
	 * @return the identity
	 */
	public String getIdentity() {
		return Identity;
	}
	/**
	 * @param identity the identity to set
	 */
	public void setIdentity(String identity) {
		Identity = identity;
	}
	/**
	 * @return the userName
	 */
	public String getUserName() {
		return UserName;
	}
	/**
	 * @param userName the userName to set
	 */
	public void setUserName(String userName) {
		UserName = userName;
	}
	/**
	 * @return the userPass
	 */
	public String getUserPass() {
		return UserPass;
	}
	/**
	 * @param userPass the userPass to set
	 */
	public void setUserPass(String userPass) {
		UserPass = userPass;
	}
	
	/**
	 * If the user logon success.
	 * True logon success.
	 * */
	public boolean logonSuccess(){
		StringBuffer sqlstr = new StringBuffer("select count(1) from ");
		if(this.Identity.equals("2")){
			sqlstr.append(TableName.ZZBaseData);
			sqlstr.append(" where "+ColumnName.ZZBDStuNo+"='"+UserName+"' and " +
					ColumnName.ZZBDPassword+"='"+UserPass+"'");
		
		}else{
			sqlstr.append(TableName.ZZManager);
			sqlstr.append(" where "+ColumnName.ZZMManagerName+"='"+UserName+"' and " +
					ColumnName.ZZMManagerPassword+"='"+UserPass+"'");
		}
		
		SpecialSQL sql = new SpecialSQL(sqlstr.toString());
		int result = new ReadSpecialResult().ReadIntResult(sql);
		if(result==1)return true;
		else return false;
	}
	
}
